package gunfire.cards;

import basemod.abstracts.CustomCard;
import com.megacrit.cardcrawl.actions.watcher.ChooseOneAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.vfx.ThoughtBubble;
import gunfire.GunfireMod;
import gunfire.actions.ElementalEffectAction;
import gunfire.characters.Taizi;
import java.util.ArrayList;

import static gunfire.GunfireMod.makeCardPath;

public class ElementGlove extends CustomCard {

    public static final String ID = GunfireMod.makeID(ElementGlove.class.getSimpleName());
    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG = makeCardPath("ElementGlove.png");
    private static final CardRarity RARITY = CardRarity.RARE;
    private static final CardType TYPE = CardType.SKILL;
    private static final CardTarget TARGET = CardTarget.ENEMY;
    public static final CardColor COLOR = Taizi.Enums.COLOR_GRAY;
    private static final int COST = 0;

    public ElementGlove() {
        super(ID, NAME, IMG, COST, DESCRIPTION, TYPE, COLOR, RARITY, TARGET);
    }

    @Override
    public void upgrade() {
        if (!this.upgraded) {
            this.upgradeName();
            this.rawDescription = cardStrings.UPGRADE_DESCRIPTION;
            this.initializeDescription();
        }
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        if(this.upgraded){
            ArrayList<AbstractCard> stanceChoices = new ArrayList<>();
            stanceChoices.add(new ElementGlove0(p, m));
            stanceChoices.add(new ElementGlove1(p, m));
            stanceChoices.add(new ElementGlove2(p, m));
            this.addToBot(new ChooseOneAction(stanceChoices));
        } else {
            int r = AbstractDungeon.cardRandomRng.random(2);
            if(r == 0){
                AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F,
                        Settings.language == Settings.GameLanguage.ZHS ? "火焰异常。" : "Burning.",
                        true));
                this.addToBot(new ElementalEffectAction(m, p, 2, GunfireMod.ElementalEffect.Burning));
            } else if(r == 1){
                AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F,
                        Settings.language == Settings.GameLanguage.ZHS ? "腐蚀异常。" : "Decay.",
                        true));
                this.addToBot(new ElementalEffectAction(m, p, 2, GunfireMod.ElementalEffect.Decay));
            } else {
                AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F,
                        Settings.language == Settings.GameLanguage.ZHS ? "雷电异常。" : "Shock.",
                        true));
                this.addToBot(new ElementalEffectAction(m, p, 2, GunfireMod.ElementalEffect.Shock));
            }
        }
    }

    @Override
    public AbstractCard makeCopy() {
        return new ElementGlove();
    }
}
